(function (w) {
    var list = function () {
            this.Init();
            return this;
    },page = 1,
        nextPage = false, c,
        activityId = "";
    list.prototype = {
        Init: function () {
            activityId = getQueryString("activityId");
            c = this;
            this.data = {"url":"/rest/v1.0/mobile/shares/activities/getPartakesByActivityId/"+page+"/"+activityId};
            netWork(this.data,this.listHandle);

            var c = this;
            iscroll = new iScroll("body", { "useTransition": true, "vScrollbar": false, "hScroll": false, "onScrollStart": function () {

            }, "onScrollEnd": function () {
                if(nextPage){
                    nextPage = false;
                    c.data = {"url":"/rest/v1.0/mobile/shares/activities/getPartakesByActivityId/"+page+"/"+activityId,"loading": c.loading,"endLoading": c.endLoading};
                    netWork(c.data,c.listHandle);
                }
            }});
            sessionStorage.setItem("list","1");
        },
        listHandle: function(data){
            var d = eval( "(" + data + ")"),html = "";
            if(!d.data || !d.data.partake || d.data.partake.length == 0){
                if(page == 1){
                    $("#join_list").append("<li style = 'text-align: center;font-size: 14px;color: #ccc;border-bottom: none;' id = 'loading'>亲！没有数据哦！</li>");
                }else{
                    $("#join_list").append("<li style = 'text-align: center;font-size: 14px;color: #ccc;border-bottom: none;' id = 'loading'>没有更多数据了</li>");
                }
                return;
            }
            for(var i = 0;i < d.data.partake.length; i++){
                html += "<li><img src = '"+ (d.data.partake[i].user? d.data.partake[i].user.images[0].imageURL:"/pages/static/mobile/images/portrait_normal.jpg") +"' onerror = 'imgError(this)'/><div><span>"+ (d.data.partake[i].user?d.data.partake[i].user.nickName:d.data.partake[i].name) +"</span><br><span>"+ d.data.partake[i].time.substring(0,10) +"</span></div><span class = 'num'>x"+ d.data.partake[i].number +"</span></li>";
            }
            $("#join_list").append(html);
            page++;
            nextPage = true;
            iscroll.refresh();
        },
        loading: function(){
            $("#join_list").append("<li style = 'text-align: center;font-size: 14px;color: #ccc;border-bottom: none;' id = 'loading'>正在加载...</li>");
        },
        endLoading: function(){
            document.getElementById("join_list").removeChild(document.getElementById("loading"));
        },
        evt: function(){
            document.addEventListener('touchmove', function (e) { e.preventDefault(); }, false);
        }
    };
    w.list = list;
})(window);

var imgError = function(obj){
    obj.src = "/pages/static/mobile/images/portrait_normal.jpg";
}
new list().evt();